<?php
/**
 * Created by PhpStorm.
 * User: 84071
 * Date: 2018-11-02
 * Time: 13:08
 */
namespace app\member\controller;


use app\common\controller\MemberBase;

class Index extends MemberBase {

    public function index(){
        if(date('G')>=4 && date('G')<8){
            $holle="早上好";
        }elseif(date('G')>=8 && date('G')<12){
            $holle="上午好";
        }elseif(date('G')>=12 && date('G')<17){
            $holle="下午好";
        }elseif(date('G')>=17 && date('G')<22){
            $holle="晚上好";
        }else{
            $holle="凌晨好";
        }
//  获取最新评论
        $comdata = array(
            'uid' => $this->cxbsuser['uid'],
            'num' => '10'
        );
        $comment = model('Comment')->getList($comdata);
        $commentlist = null;
        if(!empty($comment)){
            $commentlist = $comment['list'];
            foreach ($commentlist as $k => $v){
                switch ($v['class']){
                    case '0':
                        $v['title'] = model('Order')->where('oid',$v['oid'])->value('title');
                        break;
                    case '1':
                        $v['title'] = model('Article')->where('aid',$v['aid'])->value('title');
                        break;
                    case '2':
                        $v['title'] = model('Article')->where('aid',$v['aid'])->value('title');
                        break;
                    case '3':
                        $v['title'] = model('UserData')->where('uid',$v['aid'])->value('uname');
                        break;
                }
                $commentlist[$k] = $v;
            }
        }
        //  获取论坛最新帖子
        $bbsdata = array(
            'mid' => '102',
            'num' => '10'
        );
        $bbslist = model('Article')->get_list($bbsdata);
        //  获取今日课程
        $parttime['jinadd'] = strtotime(date("Y-m-d 00:00:00",time()));
        $parttime['jinend'] = strtotime(date("Y-m-d 23:23:23",time()));
        if($this->cxbsuser['group_id'] == '6'){
            $makenum = model('OrderMake')->where('vipuid',$this->cxbsuser['uid'])->where('maketime','>',$parttime['jinadd'])->where('maketime','<',$parttime['jinend'])->where('status','in','0,1,2')->count();
        }else{
            $makenum = model('OrderMake')->where('uid',$this->cxbsuser['uid'])->where('maketime','>',$parttime['jinadd'])->where('maketime','<',$parttime['jinend'])->where('status','in','0,1,2')->count();
        }
        //  获取未付款订单
        $ordernum = model('Order')->where('uid',$this->cxbsuser['uid'])->where('class','0')->where('playstatus','in','0,4')->count();
        $makemoney = $makemoneys = null;
        if($this->cxbsuser['group_id'] == '6'){
            //  查询老师课时费
            $makemoney = model('UserMoney')->where('uid',$this->cxbsuser['uid'])->where('money_class','0')->where('addcont','9')->order('id desc')->find();
            $makemoneys = model('UserMoney')->where('uid',$this->cxbsuser['uid'])->where('money_class','0')->where('addcont','in','3,4')->order('id desc')->find();
        }
        $this->assign([
            'bbslist' => $bbslist,
            'commentlist' => $commentlist,
            'makenum' => $makenum,
            'ordernum' => $ordernum,
            'makemoney' => $makemoney,
            'makemoneys' => $makemoneys,
        ]);
        $webs = array(
            'title' => '会员中心---'.$this->webdb['webname'],
            'keywords' => $this->webdb['webkeywords'],
            'description' => $this->webdb['description'],
        );
        $this->assign([
            'webs' => $webs,
            'holle' => $holle,
            'thistime' => time(),
        ]);
        $temps = $this->temp.'index.htm';
        return view($temps);
    }
    public function map(){
        //  获取最新评论
        $comdata = array(
            'uid' => $this->cxbsuser['uid'],
            'num' => '10'
        );
        $comment = model('Comment')->getList($comdata);
        $commentlist = null;
        if(!empty($comment)){
            $commentlist = $comment['list'];
            foreach ($commentlist as $k => $v){
                switch ($v['class']){
                    case '0':
                        $v['title'] = model('Order')->where('oid',$v['oid'])->value('title');
                        break;
                    case '1':
                        $v['title'] = model('Article')->where('aid',$v['aid'])->value('title');
                        break;
                    case '2':
                        $v['title'] = model('Article')->where('aid',$v['aid'])->value('title');
                        break;
                    case '3':
                        $v['title'] = model('UserData')->where('uid',$v['aid'])->value('uname');
                        break;
                }
                $commentlist[$k] = $v;
            }
        }
        //  获取论坛最新帖子
        $bbsdata = array(
            'mid' => '102',
            'num' => '10'
        );
        $bbslist = model('Article')->get_list($bbsdata);
        //  获取今日课程
        $parttime['jinadd'] = strtotime(date("Y-m-d 00:00:00",time()));
        $parttime['jinend'] = strtotime(date("Y-m-d 23:23:23",time()));
        if($this->cxbsuser['group_id'] == '6'){
            $makenum = model('OrderMake')->where('vipuid',$this->cxbsuser['uid'])->where('maketime','>',$parttime['jinadd'])->where('maketime','<',$parttime['jinend'])->where('status','in','0,1,2')->count();
        }else{
            $makenum = model('OrderMake')->where('uid',$this->cxbsuser['uid'])->where('maketime','>',$parttime['jinadd'])->where('maketime','<',$parttime['jinend'])->where('status','in','0,1,2')->count();
        }
        //  获取未付款订单
        $ordernum = model('Order')->where('uid',$this->cxbsuser['uid'])->where('class','0')->where('playstatus','in','0,4')->count();
        $makemoney = $makemoneys = null;
        if($this->cxbsuser['group_id'] == '6'){
            //  查询老师课时费
            $makemoney = model('UserMoney')->where('uid',$this->cxbsuser['uid'])->where('money_class','0')->where('addcont','9')->order('id desc')->find();
            $makemoneys = model('UserMoney')->where('uid',$this->cxbsuser['uid'])->where('money_class','0')->where('addcont','in','3,4')->order('id desc')->find();
        }
        $this->assign([
            'bbslist' => $bbslist,
            'commentlist' => $commentlist,
            'makenum' => $makenum,
            'ordernum' => $ordernum,
            'makemoney' => $makemoney,
            'makemoneys' => $makemoneys,
        ]);
        $temps = $this->temp.'map.htm';
        return view($temps);
    }
}